/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.ms.starter.web.framework.node;

import cn.hallele.infrastructure.util.ObjectUtil;
import cn.hallele.ms.starter.web.framework.context.ActionContext;
import com.yomahub.liteflow.core.NodeComponent;
import lombok.extern.slf4j.Slf4j;

/**
 * hallele_mc_core
 *
 * @author anle5
 * @since 2024/12/31 20:45
 */
@Slf4j
public abstract class ServiceFlow extends NodeComponent {
    /**
     * 返回默认上下文
     *
     * @param <T> ActionContext中的result
     * @return 上下文 ActionContext 子类
     */
    protected <T> ActionContext getActionContext() {
        return ObjectUtil.cast(this.getContextBean(ActionContext.class));
    }

    /**
     * 设置结果
     *
     * @param res 结果
     */
    protected void setResult(Object res) {
        this.getActionContext().setResult(res);
    }
}
